#! /usr/bin/python
# -*- coding:  utf-8 -*-
#
# accoufer : cgi script for creating/editing a new client
# 
# Copyright S.Keim 2011
# Available under the MIT licence see the COPYING file

import accoufer
import shelve
import cgi
import accerror

def run():
    clients = shelve.open(accoufer.CLIENT_PATH)
    rows = []
    for url in clients:
        if url.endswith('_'):
            continue  
        ref,name,url = clients[url]  
        row = """<tr><td><a href="./xproposals?ref=%s"><img src="../search.png" title="Proposals" /></a></td> <td><a href="./xeditoffer?ref=%s"><img src="../add.png" title="New offer"/></a></td> <td><a href="%s/index.html">%s</a></td></tr>""" % (ref,ref,url,name)
        rows.append(row)
        
    print accoufer.HTML%( "Clients", SUCCESS%"".join(rows)) 



SUCCESS = """<h1>Known services</h1><table>
<tr>
<th></th>
<th></th>
<th>Service</th>
</tr>
%s
</table>

<hr/>

<a href="./index.html">Start</a> - <a href="./xnewclient">Add a service</a>"""

if __name__=="__main__":
    run()
